package com.supermap.filetransfer.entity;

import com.supermap.filetransfer.config.ConstantConfigs;
import com.supermap.filetransfer.network.listeners.IHttpRequestListener;

import java.util.UUID;

/**
 * @author Huang.MinJie
 * @desc TODO
 * @date 2022/6/19 21:57
 */
public class DownloadEntity {
    public int serialNumber; // 线程序号
    private long childrenTaskId = System.nanoTime();// 记录任务唯一性
    private String childrenId = UUID.randomUUID().toString().replaceAll("-",""); // 记录任务唯一性
    private String applicationPackage = ConstantConfigs.Application_Package; // 应用包名称 通常指程序包的包名
    public String dirFile; // 下载的文件储存目录
    public String fileName; // 下载文件名称
    public String url; // 下载链接
    public long totalSize = 1L; // 下载总长度
    public long currentSize = 0L; // 任务当前位置
    public long beginPosition; // 下载起点
    public long endPosition; // 下载结束点

    public DownloadEntity(final int serialNumber, final String dirFile,final String fileName,final String url,final long beginPosition,final long endPosition,final long totalSize) {
        this.serialNumber = serialNumber;
        this.dirFile = dirFile;
        this.fileName = fileName;
        this.url = url;
        this.beginPosition = beginPosition<0?0:beginPosition;
        this.endPosition = endPosition<0?0:endPosition;
        this.totalSize = totalSize;
    }

    /**
     * 空参数构造器一般用于 build()方式的构建   建议不要修改 权限标识
     */
    private DownloadEntity() {
        super();
    }


    private boolean isNotEntity(String contents) {
        return contents != null && !"".equals(contents.trim());
    }

    public long getCurrentSize() {
        return currentSize;
    }

    public void setCurrentSize(long currentSize) {
        this.currentSize = currentSize<0?0:currentSize;
    }

    public int getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(int serialNumber) {
        this.serialNumber = serialNumber;
    }

    public long getChildrenTaskId() {
        return childrenTaskId;
    }

    public String getChildrenId() {
        return childrenId;
    }

    public String getApplicationPackage() {
        return applicationPackage;
    }

    public String getDirFile() {
        return dirFile;
    }

    public void setDirFile(String dirFile) {
        this.dirFile = dirFile;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public long getBeginPosition() {
        return beginPosition;
    }

    public void setBeginPosition(long beginPosition) {
        this.beginPosition = beginPosition;
    }

    public long getEndPosition() {
        return endPosition;
    }

    public void setEndPosition(long endPosition) {
        this.endPosition = endPosition;
    }
}
